<?php
/**
 * 必须通过安全验证才能进行操作的ACTION,
 * 
 * 在进行安全验证过程中如果通过验证将会触发authorized_success事件,反之触发authorized_failure事件
 * 
 * @author Leo 2010-11-19
 *
 */
abstract class AuthAction extends Action {
	/**
	 * 
	 * 执行exec前的安全检验
	 * 
	 * @uses authorized_success filter the args are $request, $response
	 * @uses authorized_failure filter the args are $request, $response
	 * @param IRequest $request
	 * @param Response $response
	 * @param Ioc $ioc
	 * @return boolean
	 */
	public function preExec($request, $response, $ioc) {
		$I = whoami ();
		if ($I->authorized) {
			fire ( 'authorized_success', $request, $response );
			return true;
		} else {
			fire ( 'authorized_failure', $request, $response );
			return false;
		}
	}
}